﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for cls_tb_HOADON_HEADER
/// </summary>
public class cls_tb_HOADON_HEADER
{
	public cls_tb_HOADON_HEADER()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public static DataTable GetByF_MACN(string F_MACN)
    {
        DataTable dt = new DataTable();
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        SqlParameter[] para = new SqlParameter[1];
        para[0] = new SqlParameter("@F_MACN", F_MACN);
        try
        {
            dt = connect.GetSelectCommand("tb_HOADON_HEADER_getbyF_MACN", para);
        }
        catch { }
        return dt;
    }
    public static string gettencosokinhdoanhbyF_MACN(string F_MACN)
    {
        string rs = "";
        DataTable dt = new DataTable();
        dt = GetByF_MACN(F_MACN);
        if (dt.Rows.Count > 0)
        {
            rs = dt.Rows[0]["tencosokinhdoanh"].ToString();
        }
        return rs;
    }
    public static string getdiachibyF_MACN(string F_MACN)
    {
        string rs = "";
        DataTable dt = new DataTable();
        dt = GetByF_MACN(F_MACN);
        if (dt.Rows.Count > 0)
        {
            rs = dt.Rows[0]["diachi"].ToString();
        }
        return rs;
    }
    public static string getmasothuebyF_MACN(string F_MACN)
    {
        string rs = "";
        DataTable dt = new DataTable();
        dt = GetByF_MACN(F_MACN);
        if (dt.Rows.Count > 0)
        {
            rs = dt.Rows[0]["masothue"].ToString();
        }
        return rs;
    }
    public static string Update(string F_MACN, string tencosokinhdoanh, string diachi, string masothue)
    {
        DatabaseConnect connect = new DatabaseConnect();
        // Tham so
        object[] values = { F_MACN, tencosokinhdoanh, diachi, masothue };
        string[] parameters = { "@F_MACN", "@tencosokinhdoanh", "@diachi", "@masothue" };
        SqlParameter[] para = new SqlParameter[parameters.Length];
        for (int i = 0; i < parameters.Length; i++)
        {
            para[i] = new SqlParameter(parameters[i], values[i]);
        }
        try
        {
            connect.ExecuteQuery("tb_HOADON_HEADER_update", para);
            return "OK";
        }
        catch
        {
            return "ERR";
        }
    }
}